Restore Change/StartTrackingTouch/StopTrackingTouch events on Slider and RangeSlider#1493
Merged
Merged
Conversation
…and RangeSlider PR #1486 removed the auto-generated addOnChangeListener/addOnSliderTouchListener methods from BaseSlider via remove-node and re-added them as hand-written Additions. However, the binding generator only produces C# events for methods it sees in the API XML — since the methods were removed from the generated API, the Change, StartTrackingTouch, and StopTrackingTouch events were no longer emitted. This caused a regression in 1.14.0.4 where Slider.Change (and touch events) were missing, breaking existing .NET consumers who used the C# event syntax. Fix: add the three events manually to SliderListenerMethods.cs for both Slider and RangeSlider, using EventHelper.AddEventHandler/RemoveEventHandler with the already- generated implementor types (IOnChangeListenerImplementor, IOnSliderTouchListenerImplementor). This is exactly what the generator would have produced had the methods remained in the generated API. The ChangeEventArgs.P0 type changes from Java.Lang.Object (old erased-generic base) to the concrete Slider/RangeSlider — a source-level improvement alongside the fix. Bump nugetVersion 1.14.0.4 -> 1.14.0.5. Fixes #1484
There was a problem hiding this comment.
Pull request overview
Restores the missing C# event surface (Change, StartTrackingTouch, StopTrackingTouch) for Material Slider and RangeSlider after the listener add/remove methods were moved to Additions/ (to avoid the ACW/implementor failures from the erased-generic base interfaces).
Changes:
- Manually re-introduces the
Change,StartTrackingTouch, andStopTrackingTouchevents forSliderandRangeSliderusingJava.Interop.EventHelperand the generated*Implementortypes. - Updates
PublicAPI.Unshipped.txtto reflect the restored public events. - Bumps
Xamarin.Google.Android.MaterialnugetVersionfrom1.14.0.4to1.14.0.5.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| source/com.google.android.material/material/Additions/SliderListenerMethods.cs | Adds manual event wrappers that mirror the generator’s typical event pattern for slider listeners. |
| source/com.google.android.material/material/PublicAPI/PublicAPI.Unshipped.txt | Captures the restored event members in the public API tracking file. |
| config.json | Increments the NuGet revision for Xamarin.Google.Android.Material to ship the fix. |
jonathanpeppers
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #1486 fixed the ACW implementor build failure (#1484) by removing the auto-generated
addOnChangeListener/addOnSliderTouchListenermethods fromBaseSliderviaremove-nodein Metadata.xml and re-adding them as hand-written Additions.However, the binding generator only produces C# events (
Change,StartTrackingTouch,StopTrackingTouch) for methods it sees in the generated API XML. Since those methods were removed from the generated API, the events were no longer emitted — causing a regression in1.14.0.4:Reported by a user in: #1484 (comment)
Fix
Add the three C# events manually to
SliderListenerMethods.csfor bothSliderandRangeSlider:Change— wrapsAddOnChangeListener/RemoveOnChangeListenerStartTrackingTouch— wrapsAddOnSliderTouchListener/RemoveOnSliderTouchListenerStopTrackingTouch— wrapsAddOnSliderTouchListener/RemoveOnSliderTouchListenerEach event uses
Java.Interop.EventHelper.AddEventHandler/RemoveEventHandlerwith the already-generated implementor types (IOnChangeListenerImplementor,IOnSliderTouchListenerImplementor). This is exactly what the generator would have produced had the methods remained in the generated API.EventArgs type change (improvement)
The old
ChangeEventArgs.P0wasJava.Lang.Object(becauseBaseOnChangeListener<S>used a generic that erased toObject). The newChangeEventArgs.P0is the concreteSliderorRangeSlidertype — a typed improvement.P1(float) andP2(bool) are unchanged.NuGet version
Xamarin.Google.Android.Material:1.14.0.4→1.14.0.5Fixes #1484